package com.forg.mvc.core.common;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.forg.mvc.core.RequestContext;
import com.forg.mvc.core.RequestMethodEnum;
import com.forg.mvc.core.RequestParam;

public class RequestUtil {
    
    public static HttpServletRequest getRequest(){
        
        return RequestContext.getRequest().getRequest();
    }
    
    public static RequestParam getParam(){
        return RequestContext.getRequest().getRequestParams();
    }
    
    public static RequestMethodEnum getMethod(){
        return RequestContext.getRequest().getRequestMethod();
    }
    
    public static String getPath(){
        return RequestContext.getRequest().getRequestPath();
    }
    
    public static String getParamStr(String key) {

        return RequestContext.getRequest().getRequestParams().getStr(key);
    }

    public static Integer getParamInt(String key) {
        return RequestContext.getRequest().getRequestParams().getInt(key);
    }

    public static int getParamIntVal(String key) {
        return RequestContext.getRequest().getRequestParams().getIntVal(key);
    }

    public static Long getParamLong(String key) {
        return RequestContext.getRequest().getRequestParams().getLong(key);
    }

    public static long getParamLongVal(String key) {
        return RequestContext.getRequest().getRequestParams().getLongVal(key);
    }

    public static Double getParamDouble(String key) {
        return RequestContext.getRequest().getRequestParams().getDouble(key);
    }

    public static double getParamDoubleVal(String key) {
        return RequestContext.getRequest().getRequestParams().getDoubleVal(key);
    }

    public static Float getParamFloat(String key) {
        return RequestContext.getRequest().getRequestParams().getFloat(key);
    }

    public static float getParamFloatVal(String key) {
        return RequestContext.getRequest().getRequestParams().getFloatVal(key);
    }
    
    public static void addParam(String key,Object val){
        RequestContext.getRequest().getRequestParams().put(key, val);
    }
    
    public static void addParamAll(Map<? extends String, ? extends Object> m){
        RequestContext.getRequest().getRequestParams().putAll(m);
    }

}
